package com.deductive.web.disposition.wq;

import com.deductive.common.core.controller.BaseController;
import com.deductive.common.core.domain.AjaxResult;
import com.deductive.common.core.page.TableDataInfo;
import com.deductive.common.utils.DateUtils;
import com.deductive.domain.wq.DispositionWqZsjjjgjzcstj;
import com.deductive.service.wq.DispositionWqZsjjjgjzcstjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 战时救治机构救治措施统计类.
 *
 * @author yexiaolong
 * @version 1.0
 * @since 2025/8/29
 */
@RestController
@RequestMapping("/treatmentMeasuresStatistics")
@Api(tags = "WQ-战时救治机构救治措施统计管理")
public class TreatmentMeasuresStatisticsController extends BaseController {

    @Resource
    private DispositionWqZsjjjgjzcstjService dispositionWqZsjjjgjzcstjService;

    @GetMapping("/list")
    @ApiOperation("战时救治机构救治措施统计列表")
    public TableDataInfo list(DispositionWqZsjjjgjzcstj data) {
        startPage();
        List<DispositionWqZsjjjgjzcstj> list = dispositionWqZsjjjgjzcstjService.list();
        return getDataTable(list);
    }

    @PutMapping("/update")
    @ApiOperation("战时救治机构救治措施统计修改")
    public AjaxResult update(@RequestBody DispositionWqZsjjjgjzcstj data) {
        try
        {
            data.setUpdateTime(DateUtils.getNowDate());
            return AjaxResult.success(dispositionWqZsjjjgjzcstjService.updateById(data));
        }
        catch (Exception e)
        {
            return AjaxResult.error(e.getMessage(),false);
        }
    }

    @PostMapping("/insert")
    @ApiOperation("战时救治机构救治措施统计新增")
    public AjaxResult insert(@RequestBody DispositionWqZsjjjgjzcstj data) {
        try
        {
            data.setCreateTime(DateUtils.getNowDate());
            return AjaxResult.success(dispositionWqZsjjjgjzcstjService.save(data));
        }
        catch (Exception e)
        {
            return AjaxResult.error(e.getMessage(),false);
        }
    }

    @DeleteMapping
    @ApiOperation("战时救治机构救治措施统计删除")
    public AjaxResult delete(@RequestParam("idList") List<Long> idList) {
        return AjaxResult.success(dispositionWqZsjjjgjzcstjService.removeByIds(idList));
    }
}
